package org.gdkm.controller;

import org.gdkm.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class RedisController {

    @Autowired
    RedisService redisService;

    @PostMapping(value = "put")
    public String put(String key,String value){
        redisService.put(key,value);
        return "success";
    }
    @GetMapping(value = "get")
    public Object get (String key){
        Object s = redisService.get(key);
        if (s!=null){
            return s;
        }
        return null;
    }
    @GetMapping("delete")
    public Boolean delete(String key){
        Boolean delete = redisService.delete(key);
        System.out.println(key);
        System.out.println("delete = " + delete);
        return delete;
    }
    @GetMapping(value = "success")
    public String test(){
        return "success";
    }
}
